package logic

import (
	"context"
	"library/models/mysql"

	"library/libraryrpc/internal/svc"
	"library/libraryrpc/libraryrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type LabelShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewLabelShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LabelShowLogic {
	return &LabelShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *LabelShowLogic) LabelShow(in *libraryrpc.LabelShowRequest) (*libraryrpc.LabelShowResponse, error) {
	// todo: add your logic here and delete this line
	var label mysql.Label
	mysql.DB.Where("id=?", in.Label).Find(&label)
	return &libraryrpc.LabelShowResponse{
		UserId:        int64(label.UserId),
		InformationId: int64(label.InformationId),
		Name:          label.Name,
		Content:       label.Content,
	}, nil
}
